package com.yc.c118s3plyqnzf.controller;

import com.yc.c118s3plyqnzf.service.BizException;
import com.yc.c118s3plyqnzf.vo.Result;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Component
@ControllerAdvice
public class MyExceptinHandler {

    @ResponseBody
    @ExceptionHandler(BizException.class)
    public Result BizExceptionHandler(BizException e){
        e.printStackTrace();
        return new Result(0, e.getMessage(), e.getData());
    }


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result ExceptionHandler(Exception e){
        e.printStackTrace();
        return new Result(0,"业务繁忙，请稍后再试", null);
    }
}
